package com.example.myspringframework.context.support;

import com.example.myspringframework.beans.BeansException;
import com.example.myspringframework.beans.factory.support.DefaultListableBeanFactory;
import com.example.myspringframework.beans.factory.xml.XmlBeanDefinitionReader;

import java.util.Arrays;

public abstract class AbstractXmlApplicationContext extends AbstractRefreshableApplicationContext{
    @Override
    protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException {
        XmlBeanDefinitionReader definitionReader = new XmlBeanDefinitionReader(beanFactory, this);
        String[] configLocations = this.getConfigLocations();
        if (configLocations != null && configLocations.length > 0) {
            definitionReader.loadBeanDefinitions(configLocations);
        }
    }
    protected abstract String[] getConfigLocations();
}
